<?php
include "inc-config.php";
include "inc-header.php";
?>



<table width="100%" border="0" cellspacing="0" cellpadding="0" style="">
  <tr>
    <td width="8" height="6px" background="images/blizzMenu/blue/rb-tleft.gif"></td>
    <td background="images/blizzMenu/blue/top.gif"></td>
    <td background="images/blizzMenu/blue/rb-tright1.gif"></td>
  </tr>
  <tr>
    <td background="images/blizzMenu/blue/rb-side.jpg" style="background-repeat:repeat-y; background-position:left"  bgcolor="#122031"></td>
    <td  bgcolor="#122031" align="center"><br /><span style="font-size: 18px; font-family:'Century Gothic', Arial, Helvetica; color:#ffffff" >Invite a Friend</span><br /><br />
<span style="color:#FFFFFF">
	<?php 
   $user=$_SESSION['user'];
   $getuser="SELECT * from b_users where username='$user'";
   $getuser2=mysql_query($getuser) or die("Could not get user info");
   $getuser3=mysql_fetch_array($getuser2);
   $ip=$_SERVER["REMOTE_ADDR"];

   
if ($getuser3[friend]<>0) {
print "You can invite $getuser3[friend] friends.<br><br>";
		   $getfrend="SELECT * from b_friends where userid='$getuser3[userID]'";
		   $getfrend2=mysql_query($getfrend);
		   $getfrend3=mysql_num_rows($getfrend2);
		   if ($getfrend3<>"0" or $getfrend3<>"") {
		   $getfrend3=mysql_query($getfrend) or die ("Die");
		   $getfrend4=mysql_fetch_array($getfrend3);
		   //************
	      if ($getfrend4[ip]<>$ip) 
		   {$upip="UPDATE b_friends SET ip='$ip' WHERE userid=$getuser3[userID]";
			mysql_query($upip) or die("Could not update IP");
		   }
		   //************
		   if ($getfrend4[link1]<>"0"){
		   print "One time expendable Link 1:<div style='background-color:#0E1825; border:solid 1px #000000; color:#00CC00; padding: 4px; margin: 5px'>".$sitepath."forum/friendregister.php?ref=$getfrend4[userid]&&a=$getfrend4[link1]</div><br>";}
		    else {print "One time expendable Link 1:<div style='background-color:#0E1825; border:solid 1px #000000; color:#CC3300; padding: 4px; margin: 5px'>USED</div><br>";}
		   if ($getfrend4[link2]<>"0"){
		   print "One time expendable Link 2:<div style='background-color:#0E1825; border:solid 1px #000000; color:#00CC00;padding: 4px; margin: 5px'>".$sitepath."forum/friendregister.php?ref=$getfrend4[userid]&&a=$getfrend4[link2]</div><br>";}
		   		    else {print "One time expendable Link 2:<div style='background-color:#0E1825; border:solid 1px #000000; color:#CC3300; padding: 4px; margin: 5px'>USED</div><br>";}

		   if ($getfrend4[link3]<>"0"){
		   print "One time expendable Link 3:<div style='background-color:#0E1825; border:solid 1px #000000; color:#00CC00;padding: 4px; margin: 5px'>".$sitepath."forum/friendregister.php?ref=$getfrend4[userid]&&a=$getfrend4[link3]</div><br>";}
		   		    else {print "One time expendable Link 3:<div style='background-color:#0E1825; border:solid 1px #000000; color:#CC3300; padding: 4px; margin: 5px'>USED</div><br>";}

		   if ($getfrend4[link4]<>"0"){
		   print "One time expendable Link 4:<div style='background-color:#0E1825; border:solid 1px #000000; color:#00CC00;padding: 4px; margin: 5px'>".$sitepath."forum/friendregister.php?ref=$getfrend4[userid]&&a=$getfrend4[link4]</div><br>";}
		   		    else {print "One time expendable Link 4:<div style='background-color:#0E1825; border:solid 1px #000000; color:#CC3300; padding: 4px; margin: 5px'>USED</div><br>";}

		   if ($getfrend4[link5]<>"0"){
		   print "One time expendable Link 5:<div style='background-color:#0E1825; border:solid 1px #000000; color:#00CC00;padding: 4px; margin: 5px'>".$sitepath."forum/friendregister.php?ref=$getfrend4[userid]&&a=$getfrend4[link5]</div><br>";}
		   		    else {print "One time expendable Link 5:<div style='background-color:#0E1825; border:solid 1px #000000; color:#CC3300; padding: 4px; margin: 5px'>USED</div><br>";}

           print "When your friend register account by following refferal link, he will gain <strong>+10</strong> bonus points<br> and you will gain <strong>+10</strong> points and <strong>+15</strong> rep.";
		   }
	else   {$ran01=rand(1000000000, 9999999999);$ran1="a$getuser3[userID]$ran01";
	        $ran02=rand(100000000, 999999999);$ran2="b$getuser3[userID]$ran02";
			$ran03=rand(10000000, 99999999);$ran3="c$getuser3[userID]$ran03";
			$ran04=rand(1000000, 9999999);$ran4="d$getuser3[userID]$ran04";
			$ran05=rand(100000, 999999);$ran5="e$getuser3[userID]$ran05";
			$ip=$_SERVER["REMOTE_ADDR"];
			
	$update="insert into b_friends (userid,link1,link2,link3,link4,link5,ip) values ($getuser3[userID],'$ran1','$ran2','$ran3','$ran4','$ran5','$ip')";
	mysql_query($update)or die(mysql_error());print "This is first time you visited this section.<br>Your refferal links has been generated, after someone register thru one of those links<br> you will gain + 10 points and +15 rep! <br><br>Please refresh this page.<br><br>";
	
	}
if ($getfrend3[link1])
    { print "no"; }


}
else {print "You have spent all 5 links. Nothing to do here.";}



?>
</td>
    <td width="8"  background="images/blizzMenu/blue/rb-side.jpg" style="background-repeat:repeat-y; background-position:right" bgcolor="#122031"></td>
  </tr>
  <tr>
    <td height="6px" background="images/blizzMenu/blue/rb-bleft.gif"></td>
    <td  background="images/blizzMenu/blue/bot.gif"></td>
    <td background="images/blizzMenu/blue/rb-bright1.gif"></td>
  </tr>
</table>

<? include "inc-footer.php"; ?>